import 'package:flutter/material.dart';
import 'gamePage.dart';

class AppPage extends StatefulWidget{
  @override
  _AppPage createState() {
    // TODO: implement createState
    return _AppPage();
  }
}
class _AppPage extends State<AppPage> with AutomaticKeepAliveClientMixin{
  ScrollController controller;
  bool showTitle;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    showTitle=false;
    controller=ScrollController();
    controller.addListener((){
      print(controller.position.pixels);
      setState(() {
        showTitle=controller.position.pixels>=40;
      });
    });
  }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: showTitle?Text("App"):Text(""),
        elevation: showTitle==true?1:0,        
      ),
      body: Container(
        color: Colors.white,
        child: CustomScrollView(
          controller: controller,
          slivers: <Widget>[
            SliverToBoxAdapter(
              child: TitleBar(
                title: "App",
              ),
            ),
            SliverList(delegate: SliverChildBuilderDelegate(
              (context,index){
                return Games_swiper();

              },
              childCount: 22
            ),)
          ],
        )
      )
    );
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;
}
